Do not update the PV_ variables with the values outputted by the bootloader --
authorEwan Mellor <ewan@xensource.com>
Thu, 28 Dec 2006 15:26:19 +0000 (15:26 +0000)
committerEwan Mellor <ewan@xensource.com>
Thu, 28 Dec 2006 15:26:19 +0000 (15:26 +0000)
this gets us into all sorts of trouble when Xend is restarted and then the
domain is rebooted, because we expect to be able to handle the PV_kernel == ''
case by defaulting to pygrub.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/XendConfig.py
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xend/image.py

index 3fb2bd0bb9f747c76010bfe231d6535d756d2364..04edbf7c1cfdc774ff06b9fdb453b3c3fe6ff703 100644 (file)
@@ -1099,21 +1099,13 @@ class XendConfig(dict):
 
         return image
 
-    def update_with_image_sxp(self, image_sxp):
+    def update_with_image_sxp(self, image_sxp, bootloader = False):
         # Convert Legacy "image" config to Xen API PV_*
         # configuration
         log.debug("update_with_image_sxp(%s)" % scrub_password(image_sxp))
 
-        self['PV_kernel'] = sxp.child_value(image_sxp, 'kernel','')
-        self['PV_ramdisk'] = sxp.child_value(image_sxp, 'ramdisk','')
-        if not self['PV_bootloader'] \
-               and sxp.child_value(image_sxp, 'kernel', ''):
-            # We've set PV_kernel using the call above, so now we need to set
-            # PV_bootloader as well, otherwise we're going to do the wrong
-            # thing on reboot.
-            self['PV_bootloader'] = 'pygrub'
         kernel_args = sxp.child_value(image_sxp, 'args', '')
-        
+
         # attempt to extract extra arguments from SXP config
         arg_ip = sxp.child_value(image_sxp, 'ip')
         if arg_ip and not re.search(r'ip=[^ ]+', kernel_args):
@@ -1121,7 +1113,16 @@ class XendConfig(dict):
         arg_root = sxp.child_value(image_sxp, 'root')
         if arg_root and not re.search(r'root=', kernel_args):
             kernel_args += ' root=%s' % arg_root
-        self['PV_args'] = kernel_args
+
+        if bootloader:
+            self['_temp_using_bootloader'] = '1'
+            self['_temp_kernel'] = sxp.child_value(image_sxp, 'kernel','')
+            self['_temp_ramdisk'] = sxp.child_value(image_sxp, 'ramdisk','')
+            self['_temp_args'] = kernel_args
+        else:
+            self['PV_kernel'] = sxp.child_value(image_sxp, 'kernel','')
+            self['PV_ramdisk'] = sxp.child_value(image_sxp, 'ramdisk','')
+            self['PV_args'] = kernel_args
 
         # Store image SXP in python dictionary format
         image = {}
index a92b706986af7e63a7262b123fd98310ce901cb4..40ff5c5effddde3350414744a72fc5527789139b 100644 (file)
@@ -1616,7 +1616,7 @@ class XendDomainInfo:
                 log.error(msg)
                 raise VmError(msg)
         
-            self.info.update_with_image_sxp(blcfg)
+            self.info.update_with_image_sxp(blcfg, True)
 
 
     # 
index d4c475c37178550a3850ec5e392e724cf66bef5d..650c449415794090f85681a21c6f95aba2bbf852 100644 (file)
@@ -68,7 +68,7 @@ class ImageHandler:
     def __init__(self, vm, vmConfig, imageConfig, deviceConfig):
         self.vm = vm
 
-        self.bootloader = None
+        self.bootloader = False
         self.kernel = None
         self.ramdisk = None
         self.cmdline = None
@@ -77,10 +77,15 @@ class ImageHandler:
 
     def configure(self, vmConfig, imageConfig, _):
         """Config actions common to all unix-like domains."""
-        self.bootloader = vmConfig['PV_bootloader']
-        self.kernel = vmConfig['PV_kernel']
-        self.cmdline = vmConfig['PV_args']
-        self.ramdisk = vmConfig['PV_ramdisk']
+        if '_temp_using_bootloader' in vmConfig:
+            self.bootloader = True
+            self.kernel = vmConfig['_temp_kernel']
+            self.cmdline = vmConfig['_temp_args']
+            self.ramdisk = vmConfig['_temp_ramdisk']
+        else:
+            self.kernel = vmConfig['PV_kernel']
+            self.cmdline = vmConfig['PV_args']
+            self.ramdisk = vmConfig['PV_ramdisk']
         self.vm.storeVm(("image/ostype", self.ostype),
                         ("image/kernel", self.kernel),
                         ("image/cmdline", self.cmdline),